<template>
    <div class="header">
      <div class="content-wrapper">
        <div class="avatar">
          <img width="64" height="64" :src="seller.avatar">
        </div>
        <div class="content">
          <div class="title">
            <span class="band"></span>
            <span class="name">{{seller.name}}</span>
          </div>
          <div class="description">{{seller.description}}/{{seller.deliveryTime + '分钟送达'}}</div>
          <div class="supports" v-if="seller.supports">
            <span class="decrease"></span>
            <span class="description">{{seller.supports[0].description}}</span>
          </div>
        </div>
        <div class="support-count" @click="showDetail">
          <span class="count" v-if="seller.supports">{{seller.supports.length}}个</span>
          <i class="icon-keyboard_arrow_right"></i>
        </div>
      </div>
      <div class="bulletin-wrapper" @click="showDetail">
        <span class="bulletin"></span><span class="text">{{seller.bulletin}}</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
      <div class="background">
        <img :src="seller.avatar" width="100%">
      </div>
      <transition name="fade">
        <div class="detail" v-show="isShowDetail">
          <div class="detail-wrapper clearfix">
            <div class="detail-main">
              <div class="name">{{seller.name}}</div>
              <star :score="seller.score" :size="48" style="margin-bottom: 24px;"></star>
              <splitline :text="content" style="margin-bottom: 24px;"></splitline>
              <ul class="supports">
                <li v-for="(support, index) in seller.supports" :key="index" class="support-item">
                  <span class="icon" :class="classMap[support.type]"></span>
                  <span class="description">{{support.description}}</span>
                </li>
              </ul>
              <splitline :text="content2" style="margin-bottom: 24px;"></splitline>
              <div class="bulletin">
                <div class="text">{{seller.bulletin}}</div>
              </div>
            </div>
          </div>
          <div class="detail-close" @click="hiddenDetail">
            <i class="icon-close"></i>
          </div>
        </div>
      </transition>
    </div>
</template>

<script>
import star from 'components/star/star.vue'
import splitline from 'components/splitline/splitline.vue'

export default {
  props: {
    seller: {
      type: Object
    }
  },
  data () {
    return {
      content: '优惠信息',
      content2: '商家公告',
      isShowDetail: false
    }
  },
  created() {
    this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
  },
  methods: {
    showDetail: function() {
      this.isShowDetail = true
    },
    hiddenDetail: function() {
      this.isShowDetail = false
    }
  },
  components: {
    star,
    splitline
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
@import '../../common/stylus/mixin.styl'
.header
  color: #fff
  position: relative
  overflow: hidden
  .content-wrapper
    display: flex
    padding: 24px 12px 18px 24px
    position: relative
    background-color: rgba(7, 17, 27, 0.4)
    .avatar
      border-radius: 2px
      overflow: hidden;
    .content
      flex: 1
      margin-left: 16px
      .title
        margin: 2px 0 8px 0
        vertical-align: top
        .band
          vertical-align: top
          display: inline-block
          base_image('brand', 30px, 18px)
        .name
          font-size: 16px
          font-weight: bold
          line-heigth: 18px
      .description
        font-size: 12px
        line-height:12px
        margin-bottom: 10px
      .supports
        display: flex
        align-items: center
        margin-bottom: 2px
        .decrease
          display: inline-block
          base_image('decrease_1', 12px, 12px)
          margin-right: 4px
        .description
          font-size: 10px
          line-height: 12px
          margin-bottom: 0
    .support-count
      position: absolute;
      right: 12px
      bottom: 18px
      padding: 7px 8px
      display: flex
      align-items: center
      justify-content: center
      border-radius: 16px
      background-color: rgba(0, 0, 0, 0.2)
      width: 36px
      height: 12px
      font-size: 12px
      .count
        margin-right: 2px
  .bulletin-wrapper
    position: relative
    height: 28px
    background-color: rgba(7, 17, 27, 0.6)
    line-height: 28px
    overflow: hidden
    text-overflow: ellipsis
    white-space: nowrap
    padding: 0 24px 0 12px
    .bulletin
      display: inline-block
      margin-right: 4px
      base_image('bulletin', 22px, 12px)
    .text
      vertical-align: top
      font-size: 10px
    i
      position: absolute
      right: 12px
      bottom: 6px
  .background
    position: absolute;
    left: 0
    top: 0
    width: 100%
    height: 100%
    object-fit: cover
    overflow: hidden;
    z-index: -1
    filter: blur(10px)
  .detail
    position: fixed
    top: 0
    left: 0
    width: 100%
    height: 100%
    overflow: auto
    opacity: 1
    background-color: rgba(7, 17, 27, 0.8)
    backdrop-filter: blur(3px)
    z-index: 50
    &.fade-enter-active, &.fade-leave-active
      transition: all .6s
    &.fade-enter, &.fade-leave
      opacity: 0
      background: rgba(7, 17, 27, 0)
    .detail-wrapper
      min-height: 100%
      width: 100%
      .detail-main
        padding: 64px 0 128px 0
        .name
          font-size: 16px
          font-weight: 700
          line-height: 32px
          text-align: center
          margin-bottom: 16px
        .supports
          margin: 0 auto 28px auto
          width: 80%
          .support-item
            display: flex
            align-items: center
            font-size: 0
            padding-left: 12px
            margin: 0 0 12px 0
            .icon
              display: inline-block
              margin-right: 6px
              &.decrease
                base_image('decrease_2', 16px, 16px)
              &.discount
                base_image('discount_2', 16px, 16px)
              &.guarantee
                base_image('guarantee_2', 16px, 16px)
              &.invoice
                base_image('invoice_2', 16px, 16px)
              &.special
                base_image('special_2', 16px, 16px)
            .description
              font-size: 12px
              line-height: 12px
      .bulletin
        margin: 0 auto
        width: 80%
        .text
          padding: 0 12px
          font-size: 12px
          line-height: 24px
    .detail-close
      position: relative;
      width: 32px
      height: 32px
      clear: both
      margin: -96px auto 0 auto
      font-size: 32px
</style>
